package cn.itsource.hrm.domain;

import com.baomidou.mybatisplus.enums.IdType;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;
import lombok.Data;

import java.io.Serializable;

/**
 * <p>
 * 会员登录账号
 * </p>
 *
 * @author gwkge
 * @since 2021-04-11
 */
@TableName("t_vip_user")
@Data
public class VipUser extends Model<VipUser> {

    private static final long serialVersionUID = 1L;
    
    // 手机认证
    public static final Long PHONE_AUTHENTICATE = 0B0000_0001L; //1
    // 邮箱认证
    public static final Long EMAIL_AUTHENTICATE = 0B0000_0010L; //2
    // 实名认证
    public static final Long REAL_AUTHENTICATE =  0B0000_0100L; //4

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    @TableField("create_time")
    private Long createTime;
    @TableField("update_time")
    private Long updateTime;
    /**
     * 三方登录名
     */
    @TableField("third_uid")
    private String thirdUid;
    /**
     * 手机号
     */
    private String phone;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 密码
     */
    private String password;
    /**
     * 头像
     */
    private String avatar;
    /**
     * 盐值
     */
    private String salt;
    /**
     * 昵称
     */
    @TableField("nick_name")
    private String nickName;
    /**
     * 用户状态
     */
    @TableField("bit_state")
    private Long bitState = 0L;
    /**
     * 安全级别
     */
    @TableField("sec_level")
    private Integer secLevel;
    @TableField("login_id")
    private Long loginId;



    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    //新增状态
    public  void addBite(Long new_state){
        bitState = bitState | new_state;
    }


    //删除状态
    public  void deleteBite(Long new_state){
         bitState = bitState ^ new_state;
    }


    //判断状态
    public  boolean judgeBite(Long state){
       return  (bitState & state) == 0L ? false : true;
    }
}
